package com.ghsc.ghxc.jsb.ui.live.view

import android.content.Context
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.cn.appcore.ext.setSingleClickListener
import com.ghsc.ghxc.jsb.R
import com.ghsc.ghxc.jsb.ui.live.fragment.LiveRedFragment
import com.lxj.xpopup.core.BottomPopupView

/**
 * 项目：GuoHuaJsb
 * 包名：com.ghsc.ghxc.jsb.ui.live.view
 * 类名：LiveRedPopupView
 * 创建时间：2024/5/23 18:00
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class LiveRedPopupView (context: Context, groupId:String, anchorId:String, liveId:String) : BottomPopupView(context) {

    override fun getImplLayoutId() = R.layout.popup_live_red
    private val mContext = context
    private val mGroupId = groupId
    private  val anchorId=anchorId
    private val liveId=liveId




    override fun onCreate() {
        super.onCreate()
        val activity = mContext as AppCompatActivity
        val beginTransaction = activity.supportFragmentManager.beginTransaction()
        val giftFragment = LiveRedFragment.newInstance(anchorId,mGroupId,liveId)
        beginTransaction.add(R.id.flContainer,giftFragment)
        beginTransaction.commit()

        findViewById<TextView>(R.id.tvBtnCancel).setSingleClickListener {
            dismiss()
        }
        findViewById<TextView>(R.id.tvColse).setOnClickListener {
            dismiss()
        }

        giftFragment.setOnDismissListener {
            this@LiveRedPopupView.dismiss()
        }

    }
    override fun getInternalFragmentNames(): MutableList<String> {
        val list = mutableListOf<String>()
        list.add(LiveRedFragment::class.java.simpleName)
        return list
    }

    override fun getMaxWidth() = 0



}